<template>
  <div style="min-width: 0">
    <el-table :data="props.tableData" class="uploadListTable">
      <el-table-column type="index" width="80" label="序号" />
      <el-table-column prop="fileName" label="名称" align="center">
        <template #default="scope">
          <span style="cursor: pointer" @click="previewFile()">{{
            scope.row.fileName
          }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="filePage" label="页数" width="100" />
      <el-table-column prop="createTime" label="创建时间" width="220" />
      <el-table-column label="操作" width="80">
        <template #default="scope">
          <img
            src="@/assets/imgs/spotCheck/upload.png"
            alt=""
            class="upload"
            @click="preview(scope.row.fileUrl)"
          />
        </template>
      </el-table-column>
    </el-table>
    <!--预览-->
    <MFileList ref="mfileList" :fileData="fileData" />
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
const props = defineProps(['tableData'])

const preview = (url) => {
  window.open(url)
}

//预览
const mfileList = ref()
const fileData = ref([])
function previewFile(it) {
  let fileDataList = props.tableData.map((i) => ({
    name: i.fileName,
    url: i.fileUrl
  }))
  console.log('fileDataList', fileDataList[0], props.tableData)
  fileData.value = fileDataList
  mfileList.value.detailsVisible = true
}
</script>

<style scoped lang="scss">
:deep(.uploadListTable th) {
  background: #f5f6f8;
  font-weight: 300;
  font-size: 16px;
  color: #333333;
  height: 38px;
}
.info {
  display: flex;
  margin-bottom: 30px;
  .info-label {
    width: 108px;
    font-family: Source Han Sans SC, Source Han Sans SC;
    font-weight: 300;
    font-size: 18px;
    color: #666666;
    margin-right: 20px;
    display: inline-flex;
    justify-content: flex-end;
    align-items: center;
    height: 30px;
  }
  .info-input {
    flex: 1;
    font-family: Source Han Sans SC, Source Han Sans SC;
    font-weight: 400;
    font-size: 18px;
    color: #333333;
    line-height: 30px;
    min-width: 0;
  }
}

.upload {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.uploadListTable {
  min-width: 500px;
  border: 1px solid #e9e9e9;
}

:deep(.uploadListTable th) {
  background: #f5f6f8;
  font-weight: 300;
  font-size: 16px;
  color: #333333;
  height: 38px;
}
.header {
  display: flex;
  align-items: center;
  .icon {
    margin-right: 16px;
    cursor: pointer;
  }
  span {
    font-family: Source Han Sans SC, Source Han Sans SC;
    font-weight: 500;
    font-size: 20px;
    color: #333333;
  }
}
</style>
